package com.waves.design.observer;

import java.util.ArrayList;

/**
 * 指挥部类
 * 抽象目标类
 * 一个被观察目标可以接受任何数量的观察者，它提供一系列方法来增加和删除观察者对象，同时还定义通知方法
 */
public abstract class AllyControlCenter {
    protected String allyName;
    protected ArrayList<Observer> players = new ArrayList<Observer>();

    public String getAllName() {
        return allyName;
    }

    public void setAllName(String allName) {
        this.allyName = allName;
    }

    public void join(Observer obs){
        System.out.println(obs.getName() + "加入" + this.allyName + "战队");
        players.add(obs);
    }

    public void quit(Observer obs){
        System.out.println(obs.getName() + "退出" + this.allyName + "战队");
        players.remove(obs);
    }

    public abstract void notifyObserver(String name);
}
